package com.zbfmq.mqlistener;

import com.rabbitmq.client.Channel;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import java.io.IOException;

/**
 * @author: LCG
 * 作者: LCG
 * 日期: 2021/3/11  9:16
 * 描述: 接收死信队列的值
 */
//@Component
//@RabbitListener(queues = {"dead-queue"})
public class MeMessageListener3 {

    @RabbitHandler
    public void mshHandler(Object messag, Message message, Channel channel) throws IOException {


        Message message1=(Message)messag;

        System.out.println("=====死信队列==111===>"+new String(message1.getBody()));

        long deliveryTag = message.getMessageProperties().getDeliveryTag();

        //手动的确认消息
        //channel.basicAck(deliveryTag,true);
        //拒绝
        //channel.basicReject(deliveryTag,true);

    }

}
